package edu.neelsys.jforum.sso;

import net.jforum.context.RequestContext;
import net.jforum.entities.UserSession;
import net.jforum.sso.SSO;

import org.springframework.security.core.context.SecurityContextHolder;

import edu.neelsys.objectmodel.userauth.LoggedUser;

public class JForumSSOImpl implements SSO {

	public String authenticateUser(RequestContext request) {

		LoggedUser user = (LoggedUser) SecurityContextHolder.getContext()
				.getAuthentication().getPrincipal();

		return user.getUsername();

	}

	public boolean isSessionValid(UserSession userSession,
			RequestContext request) {

		LoggedUser user = (LoggedUser) SecurityContextHolder.getContext()
				.getAuthentication().getPrincipal();
		if (user != null) {
			return true;

		}
		return false;

	}
}
